<?php
namespace app\admin\controller;

use app\admin\service\WxService;

class WxController extends CommonController
{
    public function initialize()
    {
        $this->noCheckTokenAction = ["wxNotify", "wxMessage", "wxAuthEvent"]; // 不需要校验登录状态了
        parent::initialize();
    }

    // 获取第三方授权地址
    public function getAuthorizationUrl(){
        $service = $this->app->invokeClass(WxService::class);
        $this->returnData = $service->getAuthorizationUrl($this->params);
        return $this->return_result($this->returnData);
    }

    // 授权给第三方平台 的回调处理方法
    public function wxNotify(){
        $service = $this->app->invokeClass(WxService::class);
        return $service->wxNotify($this->params);
    }

    // 消息与事件接收URL
    public function wxMessage($appId){
        $service = $this->app->invokeClass(WxService::class);
        return $service->wxMessage($appId, $this->params);
    }

    // 授权事件接收URL
    public function wxAuthEvent(){
        $service = $this->app->invokeClass(WxService::class);
        return $service->wxAuthEvent($this->params);
    }
}
